<?php
class Admin_RoleController extends Admin_Libraries_Controller_Action
{
	protected $_config = null;
	
	public function init() 
	{
		parent::init();
		$this->_config = Zend_Registry::get('configuration');			
		$this->_params = $this->getRequest()->getParams();		
	}		
	
	public function indexAction() {		
		if (!$this->_acl->isUserAllowed('admin:role', 'view')) 
			$this->_redirect($this->_config->site->admin->urlAccessDenied);
			
		$this->view->headScript()->appendFile( $this->_config->site->admin->jsUrl.'jform.js', 'text/javascript');		
		$arrWhere = array();	
		$filterKeyword = $this->getRequest()->getParam('filter_keyword', '');
		if ($filterKeyword != '') $arrWhere[] = 'role_name like "%'.$filterKeyword.'%"';		
		
		$cRole = new Admin_Model_Role();
		$cUser = new Admin_Model_User();		
		$utilArray = new Core_Utilities_Array();
		$this->view->arrUser = $utilArray->buildArrayWithCustomKey($cUser->getListManager(), 'id');	
		$this->view->arrRole = $cRole->getList($arrWhere);	
		$this->view->filterKeyword = $filterKeyword;
		$this->view->message = $this->showMessage($this->_helper->FlashMessenger->getMessages());
	}
}